Xoops Menus

 

 

Main Menu

The Main Menu in Xoops is integrated throughout the core files, so it can't be altered without serious coding. All modules automatically have links added to the main menu. These links normally lead to the module's first page, normally called the "index page". The link to the module in the main menu is named after the module's name. But some extra url links can be added with a little tweaking and know-how.

How to change the name of a module's link in the main menu

To do this you must change the name of the module. Go to System  Admin-> Modules. Then look for the module you wish to change the name of, and rename in the module name text box. Click "update". The link in the main menu will change to this new name.

How to re-order links in the main menu

To do this go to System  Admin-> Modules. Then look for the Order (0 = hide) column. The numbers represent the order of sequence the links will appear in the main menu, from lowest to highest i.e. 1,2,3..etc. Add your number sequence for each module and then click submit. You can add numbers with gaps between to allow the easy insertion of more modules later i.e. 4,6,8 etc

How to hide an installed module's link in the main menu

To hide a link to a module in the main menu go to System Admin-->Modules and look for the Order ( 0=Hide )  column to the right of the module. Change the "1" to a "0" (Zero). Although the link is hidden in the main menu the module is still active

How to add your own url links to your main menu

You must firstly edit the main menu files located in System Admin-> Templates-> System-> system_block_mainmenu.html

But to do this you must alter a template file. The default template cant be edited without cloning. If you are using the default Xoops template you need to click on "Clone" and then set up the clone as your default template in General Settings. You may call this clone anything you wish. If you don't call it anything Xoops will add a default name.

If you are using another theme apart from Xoops default, it it will normally be based on the Xoops default template, if not, the theme you downloaded would have a compressed file with a "tar.gz" extension to upload into templates (to create its own template)

You may need to click on "Generate" for some modules to create the editable files. These module files that need to be generated are colored red.

After you have set up your default template in general settings, go back to System Admin-> Templates--your default template will have a tick against it. Now look for the "System" set of files and click on "List"

In there you will find a file called system_block_mainmenu.html

Click on "Edit"

The file should look similar to this:

<table cellspacing="0">
<tr>
<td id="mainmenu">
<a class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>
<{foreach item=sublink from=$module.sublinks}>
<a class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
<{/foreach}>
<{/foreach}>
<!-- end module menu loop -->
<a class="menuMain" href="<{$xoops_url}>/aboutbournemouth.html">Bournemouth</a>
<a class="menuMain" href="http://www.xoops.org">Xoops CMS</a>
</td>
</tr>
</table>

Notice after the <!-- end module menu loop --> I have added a couple of lines i.e.

<a class="menuMain" href="<{$xoops_url}>/aboutbournemouth.html">Bournemouth</a>
<a class="menuMain" href="http://www.xoops.org">Xoops CMS</a>

The first line provides a link to a file on my server

The second provides a link to another site, no need for target_blank, but to open in new window add target="_blank" i.e.

<a class="menuMain" href="http://www.xoops.org" target="_blank">Xoops CMS</a>

(Remember to use the same "classes" your Template is using, these classes are defined in your style.css file in your themes folder)

These lines need to be outside the "module menu loop" You could have the links before "<!-- start module menu loop -->" which means they would appear at the top.


Hiding Submenus for Unregistered Users

Each module has any related submenus defined in the xooops_version.php file in the individual modules root folder.

For example to hide the submit menu from the anon users group in the News module look for the Menu code:

// Menu
$modversion['hasMain'] = 1;
global $xoopsUser;
if(!empty($xoopsUser)) {
$group = $xoopsUser->getGroups();

if (in_array(2, $group)) { //or other group-IDs
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
$modversion['sub'][1]['url'] = "submit.php";
}
}
$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";

In this one anon users will see the archive sub-menu only

Notice this line

if (in_array(2, $group)) { //or other group-IDs

group 2 = registered users

group 1 = webmasters

At the time of writing I understand that the next News module will have this ability included.


How to fake sub-menus using custom blocks and HTML

This is an overview for users who have a working understanding of HTML.

I was seeking to find a way to create custom blocks using HTML with menus and submenus. Someone asked me about how to do it, as they had seen this site here

I figured they probably used a variety of different blocks in exactly the same position.

It turns out it is not to hard to do this with Xoops flexible blocks power.

First you create a custom block for your "Top Page", your Top Page is whatever page is set to default in Xoops i.e. "News" or "None" if you don't wish to load a module at the start.

Go to System Admin-> Blocks and insert HTML code similar to the following for your included links in a new custom block. You will find the "classes" your style sheet is using in System Admin-> Templates, look for "System" and click on "List". Then look for system_block_mainmenu.html and click on "Edit"

This will reveal the classes your template is using which is useful if you want to match the other navigation blocks in your website. These sub-menu classes will also include in their definition some padding to indent the sub-menus. My x2t Template uses "menuMain" and "menuSub". These classes are related to your theme's style sheet in your themes folder (style.css)

To create a custom block go to System Admin-> Blocks. Name your custom block and set the visibility to the "Top Page". Then insert HTML code similar to this layout, with your own paths and links.

<div class="blockContent">
<table cellspacing="0" width="100%">
<tr>
<td id="mainmenu">
<a class="menuTop" href="http://www.macambridge.com/">Home</a>
<a class="menuMain" href="http://www.macambridge.com/modules/mypage/">My Home Town</a>
</td>
</tr>
</table></div>

Make this block only visible in the Top Page for now, you can choose other pages or modules later if required.

The "modules/mypage" link is a little one page module I made, it is very easy to do your own one page HTML modules, which create one HTML page wrapped within Xoops. You can also call these modules anything you wish. I have made one available for download with instructions on how to make any amount of clones by just altering a couple of lines.

http://www.macambridge.com/mypage.zip

The advantage of having these modules is that you can choose to make your block visible in that page only using the Xoops blocks system, because the module is listed as an option. Of course you can create another block with the same name in a link to an already existing module if you wish.

Now we create the opened "submenu" block for the destination page.

To do this create another block with the same name and position, to be made visible in the destination page i.e. for the link i.e. "My Home Town"

Note: when creating blocks you can select which modules the block is visible in by holding down Ctrl on your keyboard for multiple selection. It is also better to click on "Edit" to the right of an existing block and make your selections in the resulting dialogue box.

Insert code similar to this with your own paths.

<div class="blockContent">
<table cellspacing="0" width="100%">
<tr>
<td id="mainmenu">
<a class="menuTop" href="http://www.macambridge.com/">Home</a>
<a class="menuMain" href="http://www.macambridge.com/modules/mypage/">My Home Town</a>
<a class="menuSub" href="http://www.macambridge.com/modules/mypage/../../ modules/wfsection/article.php?articleid=3">Dorset</a>
<a class="menuSub" href="http://www.xoops.org" target="_"blank">Xoops</a>
</td>
</tr>
</table></div>

Notice I have an external link included. I can also have links to any other module, article or page.

Also notice the layout of this line, you may  need need this style for linking from the module content folder (two levels down in this example)

<a class="menuSub" href="http://www.macambridge.com/modules/ mypage/../../modules/wfsection/article.php?articleid=3"> Dorset</a>

Next, I create individual submenu blocks with the same name and position for each page or module I wish the submenu block to appear in. I can have my non-submenu blocks appear in multiple pages by clicking on "Edit" to the right of the block in my Xoops blocks admin.

Remember to call the blocks by the same name, and place in the same position--they have different id no's assigned to them by Xoops, and grant appropriate permission in "Groups".

This method is really a trick of the eye. You just make a variety of different blocks, and some destination blocks have more links than the initiating block.


Where to find other menu modules

A nice module for creating your menus is Multi-Menu

Multi Menu

 

 

 

jackj macambridge.com